package com.by.config;

import feign.Logger;
import feign.Request;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class FeiginConfig {
    /**
     * feign日志级别
     *
     * @return
     */
    @Bean
    public Logger.Level level() {
        return Logger.Level.FULL;
    }

    /**
     * 授权  每次调用远程服务时 会增加请求头
     * @return
     */
   @Bean
   public BasicAuthRequestInterceptor basicAuthRequestInterceptor(){
       System.out.println("授权zpf");
       return new BasicAuthRequestInterceptor("admins","1357");
   }

//    @Bean
//    public TokenInterceptor tokenInterceptor(){
//        return new TokenInterceptor();
//    }


   // @Bean
    public Request.Options options(){
        return new Request.Options(1, TimeUnit.MILLISECONDS,1,TimeUnit.MILLISECONDS,true);
    }
}
